import { getActualAddRate, getSaleFloatRate } from '@/utils/salePrice';
import { generateHighlightNodeForSalePrice } from '@/utils/bizUtils';

export const TABLE_COLUMNS = [
  {
    title: 'SKU编码',
    key: 'skuNo'
  },
  {
    title: '商品名称',
    key: 'productName'
  },
  {
    title: '规格',
    key: 'spec'
  },
  {
    title: '省',
    key: 'provinceName'
  },
  {
    title: '城市',
    key: 'cityName'
  },
  {
    title: '计量单位',
    key: 'unit'
  },
  {
    title: '品牌',
    key: 'brandName'
  },
  {
    title: '系列',
    key: 'series'
  },
  {
    title: '售价指导加价率',
    key: 'guideAddRate',
    width: 130
  },
  {
    title: '标准加价率',
    key: 'standardAddRate'
  },
  {
    title: '标准加价率来源',
    key: 'addRateTypeStr',
    width: 130
  },
  {
    title: '成本价',
    key: 'costPrice'
  },
  {
    title: '售价',
    children: [
      { title: '原值', key: 'oldSalePrice' },
      {
        title: '现值',
        render: (h, { row }) => generateHighlightNodeForSalePrice(h, row.oldSalePrice, row.salePrice)
      },
      {
        title: '浮动率',
        render: (h, { row }) => <span>{getSaleFloatRate(row.salePrice, row.oldSalePrice)}%</span>
      }
    ]
  },
  {
    title: '售价实际加价率', // 前端自定义字段，根据公式计算所得，仅展示，不入库
    children: [
      {
        title: '原值',
        render: (h, { row }) => <span>{ getActualAddRate(row, 'oldSalePrice') }</span>
      },
      {
        title: '现值',
        render: (h, { row }) => generateHighlightNodeForSalePrice(h, getActualAddRate(row, 'oldSalePrice'), getActualAddRate(row, 'salePrice'))
      }
    ]
  },
  {
    title: '销售面价',
    key: 'facePrice'
  },
  {
    title: '限制展示价',
    children: [
      { title: '原值', key: 'oldLimitShowPrice' },
      {
        title: '现值',
        render: (h, { row }) => generateHighlightNodeForSalePrice(h, row.oldLimitShowPrice, row.limitShowPrice)
      }
    ]
  },
  {
    title: '限制交易价',
    children: [
      { title: '原值', key: 'oldLimitTradePrice' },
      {
        title: '现值',
        render: (h, { row }) => generateHighlightNodeForSalePrice(h, row.oldLimitTradePrice, row.limitTradePrice)
      }
    ]
  }
]
